﻿using AnlianCommon.API.Commands.SheepFarmes;
using AnlianCommon.Common.Domains.SheepFarmHouse;
using AnlianCommon.Common.DTO;
using AnlianCommon.Enum;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace AnlianCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepFarmsController : ControllerBase
    {
        private readonly IMediator _mediator;

        public SheepFarmsController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 羊场添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddSheepFarms(SheepFarmsCreateCommand request, CancellationToken cancellationToken)
        {
            //雪花ID
            request.FarmNumber = YitIdHelper.NextId().ToString();
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 查询羊场
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultPage<SheepFarmsDto>> SheepFarmsQuerys(SheepFarmsQueryCommand request, CancellationToken cancellationToken)
        {
            var result =await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 羊场批量删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SheepFarmsBatchDeleteds(SheepFarmsBatchDeletedCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 羊场信息反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SheepFarmsBackFill(SheepFarmsBackFillCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 羊场信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SheepFarmsUpdates(SheepFarmsUpdateCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }

    }
}
